package com.joker.springcloud.service;

import com.joker.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author JokerKS
 * @Date 2021/12/22 14:00
 * @Version 1.0
 */
//降级操作
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
	@Override
	public Object create(Throwable throwable) {
		return new DeptClientService() {
			@Override
			public boolean addDept(Dept dept) {
				return false;
			}

			@Override
			public Dept queryById(Long id) {
				return new Dept()
						.setDeptno(id)
						.setDname("当前id=>" + id + "为空")
						.setDb_source("没有数据库");
			}

			@Override
			public List<Dept> queryAll() {
				return null;
			}
		};
	}
}
